/* $RCSFile: ADNDynCustomeropportunityrole.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynCustomeropportunityrole.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:49  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

/* Copyrights Christian Surieux 2010 */
/* Class ADNDynCustomeropportunityrole */
/* Date 2010-01-06 16:09:42Z */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
    public class ADNDynCustomeropportunityrole : DynEntity
    {
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.customeropportunityrole)
            {}

            public override Type DynType
            { get { return typeof(ADNDynCustomeropportunityrole); } }

            public override string DynTypename
            {   get{ return CrmStr.customeropportunityrole;}}

            public override DynEntity Build()
            {   return new ADNDynCustomeropportunityrole();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynCustomeropportunityrole(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynCustomeropportunityrole(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynCustomeropportunityrole(w,PrimaryKeyValue);}
        }

        static ADNDynCustomeropportunityrole(){new Ftor();} 
        
        public override bool HasOwningBusinessUnitProperty
        { get { return true; } }

        public override bool HasPrimaryField
        { get { return false; } }
        
        public ADNDynCustomeropportunityrole() : base() { }
        
        public ADNDynCustomeropportunityrole(CRMWrapperBase w,string PrimaryFieldValue)
            : base(w,CrmStr.customeropportunityrole)
        {}
        
        public ADNDynCustomeropportunityrole(CRMWrapperBase w,Guid CrmId) : base(w,CrmStr.customeropportunityrole,CrmId) { }
        
        public ADNDynCustomeropportunityrole(CRMWrapperBase w,InternalDynamicEntity e) : base(w,CrmStr.customeropportunityrole,e,null,null) { }
        
        public ADNDynCustomeropportunityrole(CRMWrapperBase w,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(w,CrmStr.customeropportunityrole,e,prop,s) { }
        
        public ADNDynCustomeropportunityrole(ResetWrapperHandler fn,string PrimaryFieldValue)
            : base(fn,CrmStr.customeropportunityrole)
        {}
        
        public ADNDynCustomeropportunityrole(ResetWrapperHandler fn,Guid CrmId) : base(fn,CrmStr.customeropportunityrole,CrmId) { }
        
        public ADNDynCustomeropportunityrole(ResetWrapperHandler fn,InternalDynamicEntity e) : base(fn,CrmStr.customeropportunityrole,e,null,null) { }
        
        public ADNDynCustomeropportunityrole(ResetWrapperHandler fn,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(fn,CrmStr.customeropportunityrole,e,prop,s) { }

        /* Properties */

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid customeropportunityroleid
        {
            get
            { return KeyPropertyValue(CrmStr.customeropportunityroleid); }
            set
            { AddKeyProperty(CrmStr.customeropportunityroleid,value); }
        }

        protected override void SetCrmIdProperty(Guid crmId)
        {
            if ( !dicProperty.ContainsKey(CrmStr.customeropportunityroleid) || KeyPropertyValue(CrmStr.customeropportunityroleid) != crmId )
                customeropportunityroleid = crmId;
        }
        public override Guid PrimaryKeyGuidValue
        {
            get
            { return customeropportunityroleid; }
            set { customeropportunityroleid = value; }
        }
        public override string PrimaryFieldName
        {
            get
            { return string.Empty;// CrmStr.opportunityroleidname; 
            }
            set
            {}
        }

        #region customer

        string _DefaultCustomerName   =   CrmStr.account;
		public string DefaultCustomerName
		{
			get
			{
				return _DefaultCustomerName;
			}
			set
			{
                switch (value)
                {
                    case CrmStr.account:
                    case CrmStr.contact:
                        _DefaultCustomerName  =   value;
                        break;
                }
			}
		}

        /// <summary>
        /// Beware : set defaults to account, to change it set DefaultCustomerName property before calling set
        /// or use SetContactCustomerid for adding contacts
        /// </summary>
        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid customerid 
        {
            get 
            {
                return CustomerPropertyValue(CrmStr.customerid);
            }
            set 
            {
                AddCustomerProperty(CrmStr.customerid,DefaultCustomerName,value);
            }
        }

        /// <summary>
        /// The entity : account or contact
        /// </summary>
        public string customerType
        {
            get 
            {
                return CustomerPropertyType(CrmStr.customerid);
            }
        }

         /// <summary>
        /// To adding contact customerids
        /// </summary>
        public void SetContactCustomerid(Guid contactid)
        {
                AddCustomerProperty(CrmStr.customerid,CrmStr.contact,contactid);
        }

        #endregion customer

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public string description
        {
            get
            { return StringPropertyValue(CrmStr.description); }
            set
            { AddStringProperty(CrmStr.description,value); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid opportunityid
        {
            get
            { return LookupPropertyValue(CrmStr.opportunityid); }
            set
            { AddLookupProperty(CrmStr.opportunityid,CrmStr.opportunity,value); }
        }

        public string opportunityName
        {
            get
            { return LookupPropertyName(CrmStr.opportunityid); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid opportunityroleid
        {
            get
            { return LookupPropertyValue(CrmStr.opportunityroleid); }
            set
            { AddLookupProperty(CrmStr.opportunityroleid,CrmStr.relationshiprole,value); }
        }

        public string opportunityroleName
        {
            get
            { return LookupPropertyName(CrmStr.opportunityroleid); }
        }

        public string opportunityroleidname
        {
            get
            { return LookupPropertyName(CrmStr.opportunityroleid); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public int opportunitystatecode
        {
            get
            { return NumberPropertyValue(CrmStr.opportunitystatecode); }
            set
            { AddNumberProperty(CrmStr.opportunitystatecode,value); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public int opportunitystatuscode
        {
            get
            { return NumberPropertyValue(CrmStr.opportunitystatuscode); }
            set
            { AddNumberProperty(CrmStr.opportunitystatuscode,value); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid owningbusinessunit
        {
            get
            { return LookupPropertyValue(CrmStr.owningbusinessunit); }
            set
            { AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid owninguser
        {
            get
            { return LookupPropertyValue(CrmStr.owninguser); }
            set
            { AddLookupProperty(CrmStr.owninguser,CrmStr.systemuser,value); }
        }

        [CrmDynAttribute(CrmStr.customeropportunityrole)]
        public Guid uniquedscid
        {
            get
            { return UniqueIdentifierPropertyValue(CrmStr.uniquedscid); }
            set
            { AddUniqueIdentifierProperty(CrmStr.uniquedscid,value); }
        }
    }
}